<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script type="text/javascript" src="../js/vue.js"></script>
  <title>过滤器</title>
</head>   
<body>
  <div id="root">
    <h2>过滤器</h2>
    <hr>
    <h3 v-if="timeStr">当前时间为： {{getNewTime()}}</h3>
    <h3 v-if="timeStr">当前时间为： {{getTime}}</h3>
    <h3 v-if="timeStr">当前时间为： {{time | timeFormater}}</h3>

    {{ }}
  </div>
  <script type="text/javascript">
    let time = new Date()
    const vm = new Vue({
      el:'#root', 
      data:{
        timeStr:'1652959566496',
        time
      },
      methods: {
        getNewTime() {
          return time.toLocaleString();
        }
      },
      computed: {
        getTime() {
          return time.toLocaleString()
        }
      },
      filters:{
        timeFormater(value) {
          console.log(value);
          return value.toLocaleString()
        }
      }
    })
  </script>
</body>
</html>